package org.example;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.socket.SocketUtil;
import cn.hutool.socket.aio.AioClient;
import cn.hutool.socket.aio.AioSession;
import cn.hutool.socket.aio.SimpleIoAction;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Socket1 {

    public static void main(String[] args) throws IOException, InterruptedException {
        AioClient aioClient=new AioClient(new InetSocketAddress("127.0.0.1", 8899), new SimpleIoAction() {
            @Override
            public void doAction(AioSession aioSession, ByteBuffer byteBuffer) {
                System.out.println("doAction");

            }
        });
        byte[] length={(byte)"fuck".length()};
        byte[] value="fuck".getBytes(StandardCharsets.UTF_8);



        byte[] oo=ArrayUtil.addAll(length,value);
        aioClient.write(ByteBuffer.wrap(oo));


        aioClient.close();


    }

}
